Skip to content

Disable build cache for release artifacts#11733

Closed
sarahchen6 wants to merge 8 commits into
masterfrom
sarahchen6/disable-build-cache-for-releases
Closed

Disable build cache for release artifacts#11733
sarahchen6 wants to merge 8 commits into
masterfrom
sarahchen6/disable-build-cache-for-releases

Conversation

@sarahchen6

@sarahchen6 sarahchen6 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Disable gradle's build cache for release artifacts

Motivation

Ensure release artifacts are assembled from a totally fresh task execution, rather than relying on potentially stale or incorrect build-cache states

Additional Notes

The build step was tested by manually running a GitLab pipeline with CI_COMMIT_TAG=test-release-cache-disabled as a variable (see EFFECTIVE_GRADLE_ARGS print lines in build job here). However, the deploy_to_maven_central job is dependent on a version commit tag that is protected by repo settings, i.e. it can only be tested during an actual release.

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: APMLP-1377

@sarahchen6 sarahchen6 added type: enhancement Enhancements and improvements tag: no release notes Changes to exclude from release notes comp: tooling Build & Tooling labels Jun 24, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)

Suite Status
Startup 🟡 warning

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.97 s 13.91 s [-0.3%; +1.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.88 s 13.02 s [-2.1%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 17.37 s 16.55 s [+0.5%; +9.4%] (maybe worse)
startup:petclinic:iast:Agent 17.38 s 17.55 s [-2.0%; +0.0%] (no difference)
startup:petclinic:profiling:Agent 17.56 s 17.31 s [+0.3%; +2.5%] (maybe worse)
startup:petclinic:sca:Agent 17.60 s 17.53 s [-0.7%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 16.51 s 16.69 s [-2.4%; +0.2%] (no difference)

Commit: 6452effc · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

Comment thread .gitlab-ci.yml Outdated
fi
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xms$GRADLE_MEMORY_MIN -Xmx$GRADLE_MEMORY_MAX -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
- export GRADLE_ARGS=" --build-cache --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS"
- export RELEASE_GRADLE_ARGS=" --no-build-cache --rerun-tasks --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Looks good, but instead of duplicating all args, I was suggest having a variable only for the different args between snapshots and release, which currently only set or disable the build cache.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of the current state? I wasn't able to extract only the release variables because we need to remove --build-cache from the original GRADLE_ARGS

@sarahchen6 sarahchen6 force-pushed the sarahchen6/disable-build-cache-for-releases branch 4 times, most recently from 7481157 to a5e1ee0 Compare June 24, 2026 20:30
@sarahchen6 sarahchen6 marked this pull request as ready for review June 25, 2026 15:18
@sarahchen6 sarahchen6 requested review from a team as code owners June 25, 2026 15:18
@sarahchen6 sarahchen6 requested review from bric3, dougqh and erikayasuda and removed request for a team June 25, 2026 15:18
Comment thread .gitlab-ci.yml Outdated
fi
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xms$GRADLE_MEMORY_MIN -Xmx$GRADLE_MEMORY_MAX -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
- export GRADLE_ARGS=" --build-cache --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS"
- "export RELEASE_GRADLE_ARGS=${CI_COMMIT_TAG:+${GRADLE_ARGS/--build-cache/--no-build-cache --rerun-tasks}}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I'd rather not forcibly rerun tasks during release. For re-run tasks I'd rather validate it in another job.

Especially for the publish job.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why double quote?

@sarahchen6 sarahchen6 Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I'd rather not forcibly rerun tasks during release. For re-run tasks I'd rather validate it in another job. Especially for the publish job.

Makes sense! IIUC the tasks run from scratch anyway after --no-build-cache, so I think the re-run can be removed entirely 🤔 ->Removed in 04cab87

Also, why double quote?

The quotes are required for the ${...} parsing. I tested valid gitlab file configurations here: https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-java/-/ci/editor

Comment thread .gitlab-ci.yml Outdated
- ./gradlew --version
- ./gradlew clean :dd-java-agent:shadowJar :dd-java-agent:check :dd-trace-api:jar :dd-trace-ot:shadowJar -PskipTests -x spotlessCheck $GRADLE_ARGS
- 'if [ -n "$CI_COMMIT_TAG" ]; then echo "=== RELEASE BUILD: assembling agent jar with build cache disabled ==="; fi'
- './gradlew clean :dd-java-agent:shadowJar :dd-java-agent:check :dd-trace-api:jar :dd-trace-ot:shadowJar -PskipTests -x spotlessCheck ${RELEASE_GRADLE_ARGS:-$GRADLE_ARGS}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Why single quotes?

@sarahchen6 sarahchen6 Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single quotes here are just to match the single quotes in the line above (needed because the : wasn't parsed correctly otherwise) and for the ${...} parsing.

Actually though, I will remove the problematic : from the logging and stick to double quotes here. ->Done in 04cab87

Comment thread .gitlab-ci.yml Outdated
- export GPG_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
- ./gradlew -PbuildInfo.build.number=$CI_JOB_ID publishToSonatype closeSonatypeStagingRepository -PskipTests $GRADLE_ARGS
- 'if [ -n "$CI_COMMIT_TAG" ]; then echo "=== RELEASE BUILD: publishing artifacts with build cache disabled ==="; fi'
- './gradlew -PbuildInfo.build.number=$CI_JOB_ID publishToSonatype closeSonatypeStagingRepository -PskipTests ${RELEASE_GRADLE_ARGS:-$GRADLE_ARGS}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the publication having the build cache is necessary, otherwise it might rebuild the jar!?

@sarahchen6 sarahchen6 Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes duh you're right! It should use build's same rebuilt jar! Reverted this in 04cab87, thanks

@sarahchen6 sarahchen6 Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind.... Let me think about this some more.

@sarahchen6 sarahchen6 marked this pull request as draft June 25, 2026 18:42
@sarahchen6 sarahchen6 force-pushed the sarahchen6/disable-build-cache-for-releases branch from 7e0e5bd to 6440971 Compare June 25, 2026 21:31
@sarahchen6 sarahchen6 force-pushed the sarahchen6/disable-build-cache-for-releases branch from 6440971 to dee36d3 Compare June 25, 2026 21:37
@sarahchen6

Copy link
Copy Markdown
Contributor Author

CI starts from clean state, so the build job builds artifacts from scratch regardless.

@sarahchen6 sarahchen6 closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling tag: no release notes Changes to exclude from release notes type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants